#include <bits/stdc++.h>
using namespace std;
int book[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> book[i];
  }
  sort(book + 1, book + n + 1, greater<int>());
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 1 || i % 2 == 2) {
      ans = ans + book[i];
    }
  }
  cout << ans;
  return 0;
}
